package com.east.sng.service.impl;

import com.east.sng.dao.TeacherDao;
import com.east.sng.entity.param.TeacherParam;
import com.east.sng.entity.result.TeacherFind;
import com.east.sng.entity.result.TeacherInfo;
import com.east.sng.service.TeacherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * @author east
 * @date: 2021/12/30
 * @Description:
 **/
@Service
public class TeacherServiceImpl implements TeacherService {
    @Autowired
    private TeacherDao teacherDao;

    @Override
    public List<TeacherInfo> findTeachers(Map<String, Object> params) {
        return teacherDao.selectTeachers(params);
    }

    @Override
    public TeacherFind findTeacher(Integer teacherId) {
        return teacherDao.selectTeacher(teacherId);
    }

    @Override
    public List<Map<String, Object>> findTeachersColumns(Integer courseTypeId) {
        return teacherDao.selectTeachersColumns(courseTypeId);
    }

    @Override
    public void addTeacher(TeacherParam teacherParam) {
        teacherDao.insertTeacher(teacherParam);
    }

    @Override
    public void editTeacher(TeacherParam teacherParam) {
        teacherDao.updateTeacher(teacherParam);
    }

    @Override
    public boolean removeTeacher(Integer teacherId) {
        return teacherDao.deleteOrRecoverTeacher(teacherId,1)>0;
    }

    @Override
    public boolean batchRemoveTeachers(List<Integer> teacherIds) {
        return teacherDao.batchDeleteOrRecoverTeachers(teacherIds,1)>0;
    }

    @Override
    public boolean recoverTeacher(Integer teacherId) {
        return teacherDao.deleteOrRecoverTeacher(teacherId,0)>0;
    }

    @Override
    public boolean batchRecoverTeachers(List<Integer> teacherIds) {
        return teacherDao.batchDeleteOrRecoverTeachers(teacherIds,0)>0;
    }
}
